﻿<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>数据列表</title>

    <!-- Bootstrap -->
    <link href="bootstrap-3.3.0/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
  <div class="container theme-showcase" role="main">
	<div class="page-header">
        <h1>数据列表</h1>
	</div>
	<div class="container theme-showcase" role="main">
		<h3>
			<a href="add.php"  target="_self"><span class="label label-default">添加</span></a>
		</h3>
	</div>
	<div class="col-md-6">
          <table class="table table-bordered">
            <thead>
              <tr>
                <th>#</th>
                <th>名称</th>
                <th>标题</th>
                <th>类型</th>
				<th>价格</th>
				<th>操作</th>
				<th>备注</th>
              </tr>
            </thead>
            <tbody>
			<?php 
			require_once "db.php";
			require_once "page.php";
			//$m = new MySql();
			//$list = $m->getAll('select * from product');
			//$list = MySql::getAll('select * from product');
			$param = array(
				'table'=>'product,type',
				'field'=>'product.id id,product.name name,product.title title,product.type type,product.price price',
				'where'=>'product.id>0',
				'order'=>'product.id asc',
				'index'=>'id',
				'join_type'=>'left join',
				'join_on'=>array('product.type=type.id'),
				'cache'=>true
			);
			$page	= new Page();
			$page->setEachNum(5);
			$page->setStyle('admin');
			$list = MySql::select($param,$page);
			?>
			<?php  foreach ($list as $k => $v) {?>
			<tr>
				<td><?php echo $v['id'];?></td>
				<td><?php echo $v['name'];?></td>
				<td><?php echo $v['title'];?></td>
				<td><?php echo $v['type'];?></td>
				<td><?php echo $v['price'];?></td>
				<td><a href="#"><span class="label label-info">修改</span></a>&nbsp;&nbsp;&nbsp;&nbsp;<span class="label label-danger">删除</span></td>
			</tr>
			<?php }?>
			<?php echo $page->show(); ?>
            </tbody>
          </table>
        </div>
	</div>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="bootstrap/dist/js/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
  <script src="bootstrap/dist/js/bootstrap.min.js"></script>
  </body>
</html>